<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 1. 盛水最多的容器 超时了这题
        // 时间复杂度：O(n^2)
        // 空间复杂度：O(1)
        var maxArea = function(height) {
            let n = height.length
            let ans = 0
            for (let left = 0; left < n - 1; left++) {
                for (let right = n - 1; right > left; right--) {
                    let prod = Math.min(height[left], height[right]) * (right - left)
                    ans = Math.max(prod, ans)
                }
            }
            return ans
        };
        console.log(maxArea([1,8,6,2,5,4,8,3,7]));
        console.log(maxArea([1, 1]));
    </script>
</body>
</html>